<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="description" content="LegoCMS">
	<#include "../include_page/link.html"/>
    <#include "../include_page/code-link.html"/>
	<script type="text/javascript">
		$(function(){
			var editor = CodeMirror.fromTextArea(document.getElementById("content"), {
		        lineNumbers: true,
		        mode: 'htmlmixed',
		        theme: 'eclipse',
		        scrollbarStyle: "simple",
		        indentUnit: 4,
		        indentWithTabs: true,
		        autoCloseTags: true,
		        autoCloseBrackets: true,
		        styleActiveLine: {nonEmpty: true},
		        lineWrapping: true,
		        extraKeys: {
		            "'<'": completeAfter,
		            "'/'": completeIfAfterLt,
		            "' '": completeIfInTag,
		            "'='": completeIfInTag,
		            "Ctrl-Space": "autocomplete",
		            "F11": function(cm) {
		                cm.setOption("fullScreen", !cm.getOption("fullScreen"));
		            },
		            "Esc": function(cm) {
		                if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
		            }
		        },
		        hintOptions: {schemaInfo: tags}
	        });
			ajaxForm($('#save-file-form'), function() {
		    	$('#save-file-form').find("[name=code]").attr("readonly", "");
			});
		});
	</script>
</head>
<body>
	<div class="app-main__inner" id="MyPagination-user-list">
		<@cmsFile code=code>
		<div class="main-card mb-3 card">
			<div class="card-body">
				<h5 class="card-title"><@t.page 'employee.info'/></h5>
				<form id="save-file-form" action="${ctx}/admin/file" ajax="true" onsubmit="return false;" class="needs-validation" novalidate>
					<input name="parentCode" type="hidden" value="${(fileInfo.parent.code)!''}" required>
					<input name="action" type="hidden" value="modify" required>
					<div class="position-relative row form-group">
						<label class="col-sm-2 col-form-label"><@t.page 'list.code'/></label>
						<div class="col-sm-10">
							<#if (fileInfo.code)??>
								<input name="code" placeholder="Code" type="text" class="form-control" value="${(fileInfo.code)!''}" readonly required>
							<#else>
								<input name="code" placeholder="Code" type="text" class="form-control" required>
							</#if>
							<div class="invalid-feedback">
                            	<@t.message 'verify.code'/>
                            </div>
						</div>
					</div>
					<div class="position-relative row form-group">
						<label class="col-sm-2 col-form-label"><@t.page 'list.name'/></label>
						<div class="col-sm-10">
							<input name="name" placeholder="Name" type="text" class="form-control" value="${(fileInfo.name)!''}" required>
							<div class="invalid-feedback">
                            	<@t.message 'verify.name'/>
                            </div>
						</div>
					</div>
					<div class="position-relative row form-group">
						<label class="col-sm-2 col-form-label"><@t.page 'list.type'/></label>
						<div class="col-sm-10">
							<select name="type" class="form-control custom-select" required>
								<@cmsFileType>
									<#list types as type>
										<#if (fileInfo.type.code)??&&type.code == fileInfo.type.code>
											<option selected="selected" value="${type.code}">${type.name}</option>
										<#else>
											<option value="${type.code}">${type.name}</option>
										</#if>
									</#list>
								</@cmsFileType>
							</select>
							<div class="invalid-feedback">
                            	<@t.message 'verify.type'/>
                            </div>
						</div>
					</div>
					<div class="position-relative row form-group">
						<label class="col-sm-2 col-form-label"><@t.page 'list.update-time'/></label>
						<div class="col-sm-10">
							<input placeholder="Update Date" class="form-control" value="${(fileInfo.updateTime)!''}" disabled>
						</div>
					</div>
					<#if fileInfo.editable>
						<div class="position-relative row form-group">
							<label class="col-sm-2 col-form-label"><@t.page 'list.content'/></label>
							<div class="col-sm-10">
								<textarea id="content" name="content" class="form-control">${(fileInfo.content)!''}</textarea>
							</div>
						</div>
					</#if>
					<div class="position-relative row form-check">
						<div class="col-sm-10 offset-sm-2">
							<button class="btn btn-secondary"><@t.page 'btn.save'/></button>
						</div>
					</div>
				</form>
			</div>
		</div>
		</@cmsFile>
	</div>
</body>
</html>